package log

import (
	"context"
	"grpc.getaway.adminspro.padmins.com/pkg/libs/log"
	"grpc.getaway.adminspro.padmins.com/pkg/support/log/logAccessor"
)

type logKey struct {
}

func WithExtraLog(ctx context.Context, prefix string) context.Context {
	return context.WithValue(ctx, logKey{}, logAccessor.NewLogger(ctx, prefix))
}

func WithContext(ctx context.Context) log.Logger {
	l, ok := ctx.Value(logKey{}).(log.Logger)
	if !ok {
		l = logAccessor.NewLogger(ctx, "")
	}
	return l
}
